//
//  CompseViewController.swift
//  weibo1
//
//  Created by Apple on 15/12/3.
//  Copyright © 2015年 Apple. All rights reserved.
//

import UIKit
import SnapKit
class CompseViewController: UIViewController {
//MARK: 关闭按钮的点击实际
    @objc private func close() {
        dismissViewControllerAnimated(true, completion: nil)
    
    }
    
    
    
    override func viewDidLoad() {
        super.viewDidLoad()

      setupUI()
    }
    //懒加载
    private lazy var textView: UITextView = {
        
        let tv = UITextView()
        //打开UITableView垂直滑动
        tv.alwaysBounceVertical = true
        
        return tv
        }()
    
    private lazy var placeHolderText: UITextField = {
        
        let lab = UITextField()
//        lab.text = "分享新鲜事....."
        lab.textColor = UIColor.grayColor()
        lab.font = UIFont.systemFontOfSize(18)
        lab.placeholder = "分享新鲜事....."
        return lab
        }()
    
   
}

extension CompseViewController {
    private func setupUI (){
        view.backgroundColor = UIColor.whiteColor()
        setNavBar()
        setUPtext()
    
    
    }
    //添加textview
    private func setUPtext() {
    
        view.addSubview(textView)
        //设置约束
        textView.snp_makeConstraints { (make) -> Void in
            make.top.left.right.equalTo(self.view)
            make.height.equalTo(ScreenH / 3)
        }
        
        //添加占位文本
        textView.addSubview(placeHolderText)
        placeHolderText.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(textView.snp_top).offset(8)
            make.left.equalTo(textView.snp_left).offset(5)
        }
        
    
    }
    
    
    
    //添加导航栏两个按钮
    private func setNavBar(){
    
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "关闭", style: .Plain, target: self, action: "close")
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "发送", style: .Plain, target: self, action: "send")
        //关闭发送的交互事件
        self.navigationItem.rightBarButtonItem?.enabled = false
        //自定义导航条
        
        let NavView = UIView(frame: CGRect(x: 0, y: 0, width: 200, height: 40))
        navigationItem.titleView = NavView
        let weiboLabel = UILabel()
        weiboLabel.text = "发微博"
        weiboLabel.tintColor = UIColor.grayColor()
        weiboLabel.font = UIFont.systemFontOfSize(17)
        
        let nameLabe = UILabel()
        nameLabe.text = UserAccountViewModel().name
        nameLabe.tintColor = UIColor.grayColor()
        nameLabe.font = UIFont.systemFontOfSize(14)
        NavView.addSubview(weiboLabel)
        NavView.addSubview(nameLabe)
        //布局
        //设置布局
        weiboLabel.snp_makeConstraints { (make) -> Void in
            make.centerX.equalTo(NavView.snp_centerX)
            make.top.equalTo(NavView.snp_top)
            
        }
        nameLabe.snp_makeConstraints { (make) -> Void in
            make.bottom.equalTo(NavView.snp_bottom)
            make.centerX.equalTo(NavView.snp_centerX)
        }

    }
    


}
